package com.axcbd.demo.controller;


import com.axcbd.demo.mqtt.MqttPushClient;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/mqtt")

public class MqttController {

    @Autowired
    private MqttPushClient mqttPushClient;

    @GetMapping("/fanopen")
    public void testPublishMessage() {
        mqttPushClient.publish("pet/control","openfan");
        System.out.println("已发送");
    }

    @GetMapping("/fanclose")
    public void testPublishMessage2() {
        mqttPushClient.publish("pet/control","stopfan");
        System.out.println("已发送");
    }
}
